package com.xmu.prcs.init;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.xmu.prcs.util.XMLReader;

/**
 * 项目初始化工作（加权限控制）
 * 
 * @author frequent
 * 
 */
public class InitBuild extends HttpServlet {

	public void init() throws ServletException {
		try {
			String path = this.getServletContext().getRealPath("/");// 项目路径
			this.getServletContext().setAttribute("path", path);
			this.getServletContext().setAttribute("msg", "启动加载完毕");
			// xml文件路径
			String xmlPath = path + "WEB-INF/authority.xml";
			this.getServletContext().setAttribute("xmlpath", xmlPath);
			// 调用方法，读入xml文件，转化为hashmap
			this.getServletContext().setAttribute("authorityMap",
					XMLReader.getAuthorityMap(xmlPath));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
